package com.biglead.userservice.controller;

import com.biglead.common.pojo.UserInfo;
import com.biglead.userservice.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/user")
@RefreshScope
public class UserController {

    @Resource
    private UserService userService;
    @Value("${auth.name}")
    private String authName;
     @Value("${server.port}")
     private String serverPort;

    @GetMapping(value = "/{id}")
    public UserInfo queryById(@PathVariable("id") Long id) {
        log.info("当前nacos 远程配置 authName {}",authName);
        log.info("查询用户信息 port {}",serverPort);
        return userService.queryById(id);
    }

    @GetMapping(value = "fromUserName/{userName}")
    public UserInfo loadUserByUsername(@PathVariable("userName") String userName) {

        log.info("查询用户信息 port {}",serverPort);
        return userService.queryByUserName(userName);
    }
}
